package com.iwayin.web.interceptor;

import java.util.Map;

import com.iwayin.core.dataobject.UserDO;
import com.iwayin.web.common.WebConstants;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * 登录拦截器:登录检查
 * 
 * @author xiaobo.feng<xiaobo.feng@foxmail.com>
 * 
 *         2011-8-9
 */
public class LoginInterceptor extends AbstractInterceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3701993154537960063L;

	@SuppressWarnings("rawtypes")
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		Map session = invocation.getInvocationContext().getSession();
		UserDO user = (UserDO) session.get(WebConstants.LOGIN_USER);
		if (user == null) {
			return Action.LOGIN;
		}
		return invocation.invoke();
	}

}
